package com.cn.redis2.dao;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.data.redis.core.script.RedisScript;
/**
 * @author Han
 */
public class MySctipt implements RedisScript<String>{
	private static final String SCRIPT = "local temp=redis.call('get','a') if not temp or temp<ARGV[1] then redis.call('set','a',ARGV[1]-0.1) end return redis.call('get','a')";
	private static final String SHA1 =  DigestUtils.sha1Hex(SCRIPT);
	/**
	 *
	 */
	@Override
	public String getSha1() {
		return SHA1;
	}

	/**
	 *
	 */
	@Override
	public Class<String> getResultType() {
		return String.class;
	}

	/**
	 *
	 */
	@Override
	public String getScriptAsString() {
		return SCRIPT;
	}
	
}
